<html>
    <title>keydown事件</title>
    <script>
        document.onkeydown = function(event){
            var keyCode = event.keyCode;

            if(keyCode == 13){
              alert("您输入了回车键")
            }
            if(keyCode == 27){
              alert("您输入了取消键")
            }
        }
      
    </script>
</html>         